package org.wyn.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CodeMD5 {

	public static String MD5_Code(String cStr){
			StringBuffer sb = new StringBuffer("");
		try {
			MessageDigest code = MessageDigest.getInstance("MD5");
			code.update(cStr.getBytes());
			byte[] b = code.digest();
			for(int i = 0 ;i < b.length;i ++)
			{
				int v = b[i]& 0xFF;
				if(v < 16)
					sb.append(0);
				sb.append(Integer.toHexString(v));
			}
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
			return sb.toString();
	}
	public static void main(String[] args) {
		System.out.println(MD5_Code("123456"));
	}

}
